package com.example.smarttrafficgitee.fragments;

import android.graphics.Rect;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

import com.example.smarttrafficgitee.R;

import java.util.List;

public class BillRecords_Adapter extends RecyclerView.Adapter<BillRecords_Adapter.ViewHolder>{

    private List<BillRecords> billRecords;

    public BillRecords_Adapter(List<BillRecords> billRecords) {
        this.billRecords = billRecords;
    }

    static class ViewHolder extends RecyclerView.ViewHolder{
        TextView tvMainSerialnumber,tvMainCarnumber,tvMainMoney,tvMainOperator,tvMainTime;
        public ViewHolder(@NonNull View itemView) {
            super(itemView);
            this.tvMainSerialnumber=itemView.findViewById(R.id.tvMainTitle1);
            this.tvMainCarnumber=itemView.findViewById(R.id.tvMainTitle2);
            this.tvMainMoney=itemView.findViewById(R.id.tvMainTitle3);
            this.tvMainOperator=itemView.findViewById(R.id.tvMainTitle4);
            this.tvMainTime=itemView.findViewById(R.id.tvMainTitle5);


        }

    }

    @NonNull
    @Override
    public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        LayoutInflater layoutInflater=LayoutInflater.from(parent.getContext());
        View view=layoutInflater.inflate(R.layout.p03rechargelogfragment_item,parent,false);
        return new ViewHolder(view);
    }

    @Override
    public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
        BillRecords billRecord=billRecords.get(position);
        holder.tvMainSerialnumber.setText(String.valueOf(billRecord.getSerialnumber()));
        holder.tvMainCarnumber.setText(String.valueOf(billRecord.getCarnumber()));
        holder.tvMainMoney.setText(String.valueOf(billRecord.getMoney()));
        holder.tvMainOperator.setText(billRecord.getOperator());
        holder.tvMainTime.setText(billRecord.getTime());

    }

    @Override
    public int getItemCount() {
        return billRecords.size();
    }

}
